<?php

App::uses('Post', 'Model');

class PostTest extends CakeTestCase {

	public function setUp() {
        parent::setUp();
        $this->Post = ClassRegistry::init('Post');
    }
	/*Desciption: testdeleteTweets()
	*The function tests if the given tweet was deleted from the database or not
	*After the delete, the data is restored back to the database
	*
	*author: Omar Safwany
	*/
	public function testdeleteTweets()
	{
		$result = $this->Post->deleteTweets(4);
		$expected = null;
		$result1 = $this->Post->deleteTweets(100);
		$expected1 = null;
		$this->assertEquals($expected, $result);
        $this->assertEquals($expected1, $result1);
		$this->Post->query("insert into posts (accID,text,postID) values(1,'FourthTweet',4)");
		$this->Post->query("insert into tweets(postID) values(4)");
		$this->Post->query("insert into tasks(taskID,accID,postID,originalMessage,sentBy)  values (6,1,4,'sixth task',4)");
		$this->Post->query("insert into tasks(taskID,accID,postID,originalMessage,sentBy)  values (7,1,4,'seventh task',4)");
		$this->Post->query("insert into tasks(taskID,accID,postID,originalMessage,sentBy)  values (8,1,4,'eighth task',4)");
		$this->Post->query("insert into tasks_has_users(taskID,userID,permissionLevel,status)  values(6,2,'assigner','accepted')");
		$this->Post->query("insert into tasks_has_users(taskID,userID,permissionLevel,status)  values(6,3,'assignee','accepted')");
		$this->Post->query("insert into tasks_has_users(taskID,userID,permissionLevel,status)  values(7,2,'assigner','accepted')");
		$this->Post->query("insert into tasks_has_users(taskID,userID,permissionLevel,status)  values(7,5,'assignee','accepted')");
		$this->Post->query("insert into tasks_has_users(taskID,userID,permissionLevel,status)  values(8,2,'assigner','accepted')");
		$this->Post->query("insert into tasks_has_users(taskID,userID,permissionLevel,status)  values(8,3,'assignee','accepted')");

}

/*Desciption: testdeleteTweets()
	*The function tests if the given tweet was deleted from the database or not
	*After the delete, the data is restored back to the database
	*
	*author: Omar Safwany
	*/
	public function testdeleteAll()
	{
		$result = $this->Post->deleteAll(100);
		$expected = null;
		$this->assertEquals($expected, $result);
}

}